package com.gaswell.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gaswell.pojo.RData;
import com.gaswell.pojo.Tank;
import com.gaswell.service.RDataService;
import com.gaswell.service.TankService;
import com.gaswell.vo.RDataVo;
import com.gaswell.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/rdata")
@Api(tags = "设备实时信息")
public class RDataController {
    @Autowired
    private RDataService rDataService;

    @Autowired
    private TankService tankService;

    @PostMapping("findLast")
    @ApiOperation(value = "根据时间查找最新设备数据")
    public Result findLast(String jh) {
        return rDataService.findLast(jh);
    }

//    @PostMapping("findLastByThree")
//    @ApiOperation(value = "根据时间查找最新设备数据   三罐")
//    public Result findLastByThree(String jh) {
//        RData lastRData = rDataService.findLastRData(jh);
//        if (lastRData == null) {
//            return Result.success(null);
//        }
//        RDataVo rDataVo = new RDataVo();
//        QueryWrapper<Tank> tankQueryWrapper = new QueryWrapper<>();
//        tankQueryWrapper.eq("jh", lastRData.getJh());
//        List<Tank> list = tankService.list(tankQueryWrapper);
//        BeanUtils.copyProperties(lastRData, rDataVo);
//        rDataVo.setTankList(list);
//        return Result.success(rDataVo);
//
//    }
}
